import { HomeBrand, HomeBanner } from '../../api/home'
const state = {
  brandList: [],
  sliders: []
}
const mutations = {
  setBrandList (state, value) {
    state.brandList = value
  },
  setSliders (state, value) {
    state.sliders = value
  }
}
const actions = {
  async getBrandList ({ state, commit }) {
    if (state.brandList.length > 0) {
      return state.brandList
    }
    const res = await HomeBrand()
    commit('setBrandList', res.result)
    return res.result
  },
  async getSliders ({ state, commit }) {
    if (state.sliders.length > 0) {
      return state.sliders
    }
    const res = await HomeBanner()
    commit('setSliders', res.result)
    return res.result
  }
}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}
